﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="采购原料中标.aspx.cs" Inherits="syc.Sale.采购原料中标" %>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>

<form id="form1" runat="server">
<asp:Label ID="BID" runat="server" Text="0" Visible="false"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
SelectCommand="SELECT t1.ID,t1.标书ID,t2.品名,t2.钢级,t2.规格,t3.名称 as 中标单位,cast(t1.数量 as float) as 数量,cast(t1.单价 as float) 单价,t1.合同ID,t4.编号 as 合同编号,t1.备注 FROM 采购原料中标 t1
left outer join 原料 t2 on t2.ID=t1.原料ID
left outer join 原料供货单位 t3 on t3.ID=t1.供货ID
left outer join 采购原料合同 t4 on t4.ID=t1.合同ID
where t1.标书ID=@BID"
DeleteCommand="delete from 采购原料中标 where ID=@ID;update 采购原料标书 set 条目=条目-1 where ID=@标书ID;delete from 采购原料合同 where 中标ID=@ID;"
UpdateCommand="update 采购原料中标 set 数量=@数量,单价=@单价,备注=@备注 where ID=@ID"
InsertCommand="insert into 采购原料中标(标书ID,原料ID,供货ID,数量,单价,备注)values(@标书ID,@原料ID,@供货ID,@数量,@单价,@备注);update 采购原料标书 set 条目=条目+1 where ID=@标书ID;"
onselected="SqlDataSource1_Selected" >
<InsertParameters>
<asp:Parameter Name="标书ID" DbType="Int32" Size="4" />
<asp:Parameter Name="原料ID" DbType="Int32" Size="4" />
<asp:Parameter Name="供货ID" DbType="Int32" Size="4" />
<asp:Parameter Name="数量" DbType="Decimal" Size="9"/>
<asp:Parameter Name="单价" DbType="Currency" Size="8"/>
<asp:Parameter Name="备注" DbType="String"  Size="100"/>
</InsertParameters>
<SelectParameters>
<asp:Parameter Name="BID" DbType="Int32" Size="4" DefaultValue="0" />
</SelectParameters>
</asp:SqlDataSource>
    
<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    SelectCommand="SELECT [ID], [名称] FROM [原料供货单位]" ></asp:SqlDataSource>
    
<asp:SqlDataSource ID="SqlDataSource3" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    SelectCommand="SELECT [ID], [品名]+'('+[钢级]+')'+' '+规格 as 品名 FROM [原料]"></asp:SqlDataSource>
    
<div id="wintop" class="wintop" style="display:none">标书中标明细</div>

<asp:Panel ID="Panel1" runat="server" CssClass="panel">

<asp:Button ID="Button_Info" runat="server" Text="基本信息" UseSubmitBehavior="false" CssClass="button" />
<input type="button" value="关 闭" class="button" onclick="parent.swin2_close();" />
</asp:Panel>

<asp:Panel ID="Panel2" runat="server" CssClass="panel" GroupingText="添加标书明细">
原料类别：<asp:DropDownList ID="YuanLiao" runat="server" Width="220px" Font-Size="12px"
        DataSourceID="SqlDataSource3" DataTextField="品名" DataValueField="ID" >
</asp:DropDownList>
<span style="margin-left:10px;"></span>
中标单位：<asp:DropDownList ID="GongHuo" runat="server" Width="120" 
        DataSourceID="SqlDataSource2" DataTextField="名称" DataValueField="ID"></asp:DropDownList>
<span style="margin-left:50px;"></span>
<asp:Label ID="Message" runat="server" Text="" ForeColor="Red"></asp:Label>

<div style="font-size:4px;line-height:4px;height:4px;"></div>

中标数量：<asp:TextBox runat="server" ID="ShuLiang" CssClass="textbox" width="100">
    </asp:TextBox>吨
<span style="margin-left:33px;"></span>
中标单价：<asp:TextBox runat="server" ID="DanJia" CssClass="textbox" width="100">
    </asp:TextBox>元
<span style="margin-left:10px;"></span>
备注：<asp:TextBox runat="server" ID="BeiZhu" CssClass="textbox" width="160">
    </asp:TextBox>
<asp:Button ID="Button_Add" runat="server" Text="增 加" 
    CssClass="mbutton" UseSubmitBehavior="false" onclick="Button_Add_Click" />
</asp:Panel>

<style>
tr.tr.grid-row-normal{cursor:default;}
</style>
<div class="gridframe" style="padding:5px;">
    <div class="gridview">
    
        <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
            <tr>
	            <td class="grid-title">中标明细</td>
	        </tr>
	        <tr>
	            <td class="grid-back">
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CssClass="grid" DataKeyNames="ID,标书ID" 
                        DataSourceID="SqlDataSource1" 
                        GridLines="None" ondatabound="GridView1_DataBound" 
                        onpageindexchanged="GridView1_PageIndexChanged" AllowSorting="True" 
                        UseAccessibleHeader="False" >
                        <PagerSettings Visible="False" />
                        <RowStyle CssClass="grid-row-normal" />
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <img src="/Icons/online.gif" style="margin-top:2px;" alt="" />
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="20px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="中标单位">
                                <ItemTemplate>
                                    <asp:Label ID="Label_zb" runat="server" Text='<%# Eval("中标单位") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="原料类别">
                                <ItemTemplate>
                                    <asp:Label ID="Label_pm" runat="server" Text='<%# Eval("品名") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                            </asp:TemplateField>
                             <asp:TemplateField HeaderText="钢 级">
                                <ItemTemplate>
                                    <asp:Label ID="Label_gj" runat="server" Text='<%# Eval("钢级") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="规 格">
                                <ItemTemplate>
                                    <asp:Label ID="Label_gg" runat="server" Text='<%# Eval("规格") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="100px" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="合同编号" Visible="false">
                                <ItemTemplate>
                                    <asp:Label ID="Label_ht" runat="server" Text='<%# Eval("合同编号") %>'></asp:Label>
                                    <input type="button" class="mbutton" value="录入合同" style='display:<%# ((int)Eval("合同ID")==0) ? "":"none" %>' onclick='hetong(<%# Eval("ID") %>)' />
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="70px" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="数量(吨)">
                                <ItemTemplate>
                                    <asp:Label ID="Label_sl" runat="server" Text='<%# Eval("数量") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox runat="server" ID="Edit_ShuLiang" Text='<%# Bind("数量") %>' CssClass="textbox" width="100%"></asp:TextBox>
                                </EditItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Right" Width="70px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="单价(元)">
                                <ItemTemplate>
                                    <asp:Label ID="Label_dj" runat="server" Text='<%# Eval("单价") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox runat="server" ID="Edit_DanJia" Text='<%# Bind("单价") %>' CssClass="textbox" width="100%"></asp:TextBox>
                                </EditItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Right" Width="70px" />
                            </asp:TemplateField>
                            
                            
                            <asp:TemplateField HeaderText="备注">
                                <ItemTemplate>
                                    <asp:TextBox runat="server" ID="Item_BeiZhu" Text='<%# Eval("备注") %>' ReadOnly="true" CssClass="noborder"></asp:TextBox>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox runat="server" ID="Edit_BeiZhu" Text='<%# Bind("备注") %>' CssClass="textbox" width="100%"></asp:TextBox>
                                </EditItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="100px" />
                            </asp:TemplateField>
                                                       
                            <asp:TemplateField HeaderText="操作" >
                                <ItemTemplate>
                                    <asp:Button ID="Button_Edit" runat="server" CommandName='Edit' Text="修 改" CssClass="mbutton" UseSubmitBehavior="false" />
                                    <asp:Button ID="Button_Delete" runat="server" CommandName='Delete' Text="删 除" CssClass="mbutton" UseSubmitBehavior="false" OnClientClick="if(!confirm(msg))return(false);" />
                               </ItemTemplate>
                               <EditItemTemplate>
                                    <asp:Button ID="Button_Update" runat="server" CommandName='Update' Text="更 新" CssClass="mbutton" UseSubmitBehavior="false" />
                                    <asp:Button ID="Button_Cancel" runat="server" CommandName='Cancel' Text="取 消" CssClass="mbutton" UseSubmitBehavior="false" />
                               </EditItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="124px" />
                            </asp:TemplateField>
                            

                        </Columns>
                      </asp:GridView>
	            </td>
            </tr>
            <tr>
	            <td>   
	                <table width="100%">
	                    <tr>
	                        <td class="pagebar">
                                <asp:Button ID="Button_Pager_First" runat="server" Text="" ToolTip="首页" 
                                    CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" UseSubmitBehavior="false" />
                                <asp:Button ID="Button_Pager_Prev" runat="server" Text="" ToolTip="上一页" 
                                    CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" UseSubmitBehavior="false" />
                                <input type="button" class="page-split" disabled />第<asp:TextBox ID="TextBox_Pager" runat="server" CssClass="pageturn" AutoPostBack="true"
                                    ontextchanged="Pager_Click"></asp:TextBox>页<input type="button" class="page-split" disabled /><asp:Label ID="Label_Pages" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                                
                                <asp:Button ID="Button_Pager_Next" runat="server" Text="" ToolTip="下一页" 
                                    CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+"  UseSubmitBehavior="false"/>
                                <asp:Button ID="Button_Pager_Last" runat="server" Text="" ToolTip="末页" 
                                    CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" UseSubmitBehavior="false" /><asp:Label ID="Label9" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                            </td>
                            <td class="pagebar" align="right">
                                <asp:Label ID="Label_Total" runat="server"></asp:Label>
                            </td>
                        </tr>
                   </table>

	            </td>
            </tr>
        </table>
        

    </div>
</div>

</form>
<script type="text/javascript">
var msg = '确认要删除该条记录吗？';
function hetong(zid) {
    parent.swin2_load("/Sale/采购原料合同录入.aspx?zid=" + zid+"&bid=<%=this.BID.Text %>", 720, 398);
}
document.onkeydown = function(e) {
    if (!e) e = window.event;
    var tag = e.srcElement;
    if (!tag) tag = e.target;
    if (tag.tagName != "INPUT" || tag.className != "textbox") return;
    if (e.keyCode == 13) e.keyCode = 9;
}
var textboxs = document.getElementsByTagName("input");
var i;
for (i = 0; i < textboxs.length; i++) {
    if (textboxs[i].className == "textbox") {
        //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
        textboxs[i].onfocus = function(e) { this.select(); };
    }
    else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
        textboxs[i].onfocus = function(e) { this.select(); };
    }
}
setTimeout("document.getElementById('ShuLiang').focus();", 100);

</script>
</body>
</html>
